home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 August: Tool Chest / Dev.CD Aug 94.toast / Sample Code / AppsToGo / DTS.Lib / DTS.Lib.headers / GWLayers.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-03-24  |  8.7 KB  |  198 lines  |  [TEXT/MPS ]

  1. #ifndef __GWLAYERS__
  2. #define __GWLAYERS__
  3.  
  4. #ifndef __TYPES__
  5. #include "Types.h"
  6. #endif
  7.  
  8. #ifndef __MEMORY__
  9. #include <Memory.h>
  10. #endif
  11.  
  12. #ifndef __QDOFFSCREEN__
  13. #include <QDOffscreen.h>
  14. #endif
  15.  
  16. #ifndef __QUICKDRAW__
  17. #include <Quickdraw.h>
  18. #endif
  19.  
  20. struct LayerRec;
  21. typedef struct LayerRec *LayerRecPtr, **LayerObj;
  22.  
  23. typedef OSErr (*LayerProc)(LayerObj theLayer, short message);
  24.  
  25. typedef struct LayerRec {
  26.     LayerObj        aboveLayer;
  27.     LayerObj        belowLayer;
  28.     Boolean         layerOwnsPort;
  29.     GrafPtr            layerPort;
  30.     GDHandle        layerGDevice;
  31.     Handle            layerBitmap;
  32.     short            layerDepth;
  33.     LayerProc        layerProc;
  34.     unsigned long    layerData;
  35.     short            xferMode;
  36.     Rect            srcRect;
  37.     Rect            dstRect;
  38.     Rect            thisUpdate;
  39.     Rect            lastUpdate;
  40.     Boolean            includeLastUpdate;
  41.     Boolean            lockedCount;
  42.     Boolean            cachedCount;
  43.     CGrafPtr        cachedPort;
  44.     GDHandle        cachedGDevice;
  45. } LayerRec;
  46.  
  47. #define kLayerInit    0
  48. #define kLayerDispose 1
  49. #define kLayerUpdate  2
  50.  
  51. OSErr    NewLayer(LayerObj *newLayer, LayerObj aboveLayer, LayerProc theProc,
  52.                  GrafPtr basePort, short depth, unsigned long theData);
  53. /* Use this call to create a layer object.
  54. ** newLayer:     Layer object handle returned here.
  55. ** aboveLayer:   Layer object above this layer (if any) in the layer hierarchy.
  56. **                 If none, pass in nil.
  57. ** theProc:      Layer definition procedure.  Use nil for default behaviors.
  58. ** basePort:     If the port or GWorld for the layer already exists, such as a window,
  59. **               pass it here.  If you want a GWorld created for you, pass in nil.
  60. ** depth:         Pass in a non-0 value if you want a specific depth.  If you pass in 0,
  61. **                 the the depth of the above layer will be used.
  62. ** theData:      Optional data reference.
  63. */
  64.  
  65. void    DetachLayer(LayerObj theLayer);
  66. /* Use this call to remove a layer from a layer hierarchy.  This call does
  67. ** not dispose of the layer. */
  68.  
  69. OSErr    DisposeLayer(LayerObj theLayer);
  70. /* Dispose of the layer.  If the layer belongs to a hierarchy, it is first
  71. ** removed from that hierarchy. */
  72.  
  73. OSErr    DisposeThisAndBelowLayers(LayerObj theLayer);
  74. /* Dispose of the layer and all layers below it in the hierarchy. */
  75.  
  76. short    GetLayerPosition(LayerObj theLayer);
  77. /* Return the layer position in the hierarchy.  0 is the top layer. */
  78.  
  79. LayerObj    GetTopLayer(LayerObj theLayer);
  80. /* Return the top layer in the hierarchy. */
  81.  
  82. LayerObj    GetBottomLayer(LayerObj theLayer);
  83. /* Return the bottom layer in the hierarchy. */
  84.  
  85. void    InsertLayer(LayerObj theLayer, LayerObj referenceLayer, short pos);
  86. /* Insert a layer into a hierarchy.  Passing a 0 for position makes the layer
  87. ** the top layer. */
  88.  
  89. OSErr    UpdateLayer(LayerObj theLayer);
  90. /* Given that a layer update has been posted, do the update.  LayerUpdate does
  91. ** a recursive update from theLayer down.  If there is a layer below, it calls
  92. ** LayerUpdate for that layer.  Once the bottom of the hierarchy is reached,
  93. ** the layerProc is called to do the update.  This causes the layer updates to
  94. ** occur from bottom up. */
  95.  
  96. Rect    GetEffectiveSrcRect(LayerObj theLayer);
  97. /* The effectiveSrcRect is srcRect or portRect of the layer.  If there is no srcRect,
  98. ** (srcRect is empty), then effectiveSrcRect is the layer's portRect. */
  99.  
  100. Rect    GetEffectiveDstRect(LayerObj theLayer);
  101. /* The effectiveDstRect is dstRect or portRect of the layer.  If there is no dstRect,
  102. ** (dstRect is empty), then effectiveDstRect is the layer's portRect. */
  103.  
  104. OSErr    DefaultLayerProc(LayerObj theLayer, short message);
  105. /* The three currently defined message definitions are:
  106. **
  107. ** kLayerInit:     Called by NewLayer.  If layerPort is nil (which was
  108. **                 initialized by NewLayer), then the size/depth of the GWorld
  109. **                 that is created is dependent on aboveLayer.  If there is no
  110. **                 aboveLayer, this is an error, and paramErr is returned.
  111. **                 If the GWorld is successfully created, then layerOwnsPort is
  112. **                 set true.
  113. ** kLayerDispose:  Called when a layer is disposed of by either DisposeLayer or
  114. **                 DisposeThisAndBelowLayers.  It disposes of the GWorld if the
  115. **                 GWorld is owned by the layer.
  116. ** kLayerUpdate:   If there is a below layer, kLayerUpdate does a CopyBits from the
  117. **                 below layer into the current layer.  The copy is done from the
  118. **                 below layer's effectiveSrcRect into the current layer's
  119. **                 effectiveDstRect.  The transfer mode used is in xferMode, which
  120. **                 by default is srcCopy. */
  121.  
  122. Rect    UpdateUpdateRects(LayerObj theLayer);
  123. /* Return the rect that is to be updated, plus manage lastUpdate/thisUpdate
  124. ** so that they apply to the next update. */
  125.  
  126. void    InvalLayer(LayerObj theLayer, Rect invalRect, Boolean includeLastUpdate);
  127. /* Post a layer update rect.  The rect is unioned into the thisUpdate for the
  128. ** layer and all layers below this layer.  If includeLastUpdate is true, then
  129. ** the field includeLastUpdate is set true for each layer, as well.  This boolean
  130. ** is used by the default update behavior to determine if the area last updated
  131. ** should be updated again.  This makes animation effects easier in the the old
  132. ** and new position for a player being moved are updated at the same time.  This
  133. ** could be handled by hand by calculating the rect to be updated to include the
  134. ** last position, but by passing includeLastUpdate as true, it is
  135. ** handled automatically. */
  136.  
  137. void    SetLayerWorld(LayerObj theLayer);
  138. /* This is a convenient call for setting a GWorld, while remembering what
  139. ** the previous GWorld was.  This should be balanced with a call to
  140. ** ResetLayerWorld.  A count of how many times this is called is kept
  141. ** so that the old GWorld is cached only if SetLayerWorld is currently
  142. ** in balance with ResetLayerWorld.  This keeps the oldest kept GWorld
  143. ** from being overwritten by subsequent calls. */
  144.  
  145. void    ResetLayerWorld(LayerObj theLayer);
  146. /* This is used to undo a call to SetLayerWorld.  Calls to ResetLayerWorld
  147. ** should be balanced with previous calls to SetLayerWorld. */
  148.  
  149. void    LockLayerWorld(LayerObj theLayer);
  150. /* This is a convenient way to lock down the pixels for a layer's GWorld.
  151. ** A locked count is kept to make sure that the GWorld is locked only the
  152. ** first time this is called.  Calls to LockLayerWorld will most likely
  153. ** be balanced by calls to UnlockLayerWorld, but not necessarily.  It may
  154. ** be desirable to keep a GWorld layer locked.  In this case, right after
  155. ** creating the layer (and indirectly its GWorld), call LockLayerWorld.
  156. ** This will initially lock it.  Subsequent calls would be balanced, and
  157. ** therefore there will always be one more LockLayerWorld call than
  158. ** UnlockLayerWorld calls.  This will keep it locked. */
  159.  
  160. void    UnlockLayerWorld(LayerObj theLayer);
  161. /* This undoes what LockLayerWorld does.  Calls to UnlockLayerWorld will
  162. ** generally be balanced with calls to LockLayerWorld. */
  163.  
  164. RgnHandle    ScreenDepthRegion(short depth);
  165. /* This returns a region describing the area of the various screens that is at least as deep
  166. ** as the value passed in.  So, if you want to find out what area of the screens has at least
  167. ** an 8-pixel depth, pass in an 8, and the region returned will describe that area.  If you
  168. ** want the screen area that is exactly 8 pixels deep, call this function with an 8, and then
  169. ** call it again with a 9.  Diff out the region returned when 9 was passed in.  The remaining
  170. ** area is the area that is exactly 8 pixels deep.  (Dispose of both regions when you are done
  171. ** with them.) */
  172.  
  173. CIconHandle    ReadCIcon(short iconID);
  174. /* This function is for system 6/7 compatibility.  System 6 doesn't normally have color icon
  175. ** support, and if you call the 'cicn' functions in system 6, you will get an unimplemented
  176. ** trap error.  ReadCIcon calls the color QuickDraw trap GetCIcon if it is available, or it
  177. ** simply calls GetResource/ReleaseResource if the trap isn't available. */
  178.  
  179. void        KillCIcon(CIconHandle icon);
  180. /* This call disposes of a 'cicn' handle gotten by calling ReadCicon. */
  181.  
  182. void        DrawCIcon(CIconHandle icon, Rect destRect);
  183. /* This function calls PlotCIcon if it is available, or it dereferences the 1-bit deep bitmap
  184. ** of the 'cicn' and does a CopyBits if it isn't. */
  185.  
  186. void        DrawCIconNoMask(CIconHandle icon, Rect destRect);
  187. /* This function calls PlotCIcon with a temporary mask of nothing masked if it is available,
  188. ** or it dereferences the 1-bit deep bitmap of the 'cicn' and does a CopyMask if it isn't. */
  189.  
  190. void        DrawCIconByDepth(CIconHandle icon, Rect destRect, short depth, Boolean useMask);
  191. /* This call does either a CopyBits or CopyMask of the correct part of the 'cicn' resource.
  192. ** The correct part is determined by the depth.  If a specific depth of 1 is requested, then
  193. ** the bitmap portion of the 'cicn' is plotted.  If a specific depth of greater than 1 is
  194. ** requested, and the depth of the target is greater than 1, then the pixmap portion of the 
  195. ** 'cicn' is plotted. */
  196.  
  197. #endif
  198.